/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.vienthona.common.utils;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.xpath.XPath;


/**
 *
 * @author DoanHa
 */
public class ProductUtils {
    public static String getImagePath(String pPhoto, int index) {
        String[] arr = pPhoto.split(";");

        if(index == 0)
        {
            if(arr.length >= 1)
                return arr[index];
            else
                return "";
        }
        else
            if(index == 1)
            {
                if(arr.length >= 2)
                    return arr[index];
                else
                    return "";
            }
        return "";
    }

    public static String getElementValue(Document doc,String xPath)
    {
        try
        {
            Element element = (Element)XPath.selectSingleNode(doc, xPath);
            return element.getText();
        }
        catch(Exception ex)
        {
            return "";
        }

    }
}
